﻿
Public Class stopbubble
    Public Const functionName As String = "stbb"

    Public Shared Sub register(ByVal inlineScript As inlineScript)
        assert(Not inlineScript Is Nothing, "inlineScript is nothing.")
        [true].register(inlineScript)
        inlineScript.addscript("stopbubble", "function " + functionName + "(e){" + _
                               "e=" + questioncolon.invoke("e", "e", window.name(inlineScript) + ".event") + ";" + _
                               ifelse.invoke(window.name(inlineScript) + ".event", _
                                             "e.cancelBubble=" + [true].name(inlineScript), _
                                             "e.stopPropagation()") + "}")
    End Sub

    Public Shared Function invoke(ByVal inlineScript As inlineScript, _
                                  Optional ByRef actionTarget As String = Nothing) As String
        If Not inlineScript Is Nothing Then
            register(inlineScript)
        End If

        actionTarget += functionName + "(event)"
        Return actionTarget
    End Function
End Class
